const express = require('express');
const router = express.Router();
const db = require('../db/db');

router.post('/api/create', (req, res) => {
    let create = new db.Question.Model({
        _id: new db.Mongoose.Types.ObjectId(),
        title: req.body.title,
        content: req.body.content,
        createTime: new Date(),
        author: req.session.user._id
    }).save().then(result => {
        console.log('添加问题成功', result)
        res.send({ code: 0, message: '添加问题成功' })
    }).catch(err => {
        console.log('添加问题失败', err)
    })
})

module.exports = router;